package com.qfedu.cardlikelazy.service.impl;

import com.qfedu.cardlikelazy.domain.Card;
import com.qfedu.cardlikelazy.mapper.CardMapper;
import com.qfedu.cardlikelazy.response.R;
import com.qfedu.cardlikelazy.service.CardService;
import com.qfedu.cardlikelazy.utils.StringUtils;
import jdk.nashorn.internal.ir.CallNode;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CardServiceImpl implements CardService {

    @Resource
    private CardMapper mapper;

    @Override
    public R insert(Card card) {
         int insert = mapper.insert(card);
         if (insert>0){
             return R.ok("添加成功");
         }
        return R.fail("新增失败");
    }

    @Override
    public R selectById(int id) {
        return R.ok( mapper.selectById(id));
        }


    @Override
    public R selectAll() {
        List<Card> list;
        list = mapper.selectAll();
        if (list!=null){
            return R.ok(list);
        }
        return R.fail("网络异常！");
    }
}
